package com.feiyu.stackqueue;

import java.util.ArrayList;

/**
 * @Author nanshouxiao@teacher.com.cn
 * @Date 2017-10-27 15:54
 */
public class Stack<T> extends BaseStackQueue<T> {

    public Stack() {
        super();
    }

    public Stack(int capacity) {
        super(capacity);
    }

    @Override
    public T pop() {
        if (!isEmpty()) {
            return (T) datas[top--];
        }
        return null;
    }

    @Override
    public T peek() {
        if (!isEmpty()) {
            return (T) datas[top];
        }
        return null;
    }

    @Override
    public T push(T o) {
        if (!isFull()) {
            datas[++top] = o;
        }
        return o;
    }

}
